# coding:utf-8
from qtpy.QtCore import QEasingCurve, QPropertyAnimation, Qt, QEvent
from qtpy.QtGui import QColor, QResizeEvent
from qtpy.QtWidgets import (QDialog, QGraphicsDropShadowEffect, QGraphicsOpacityEffect, QHBoxLayout, QWidget, QFrame)

from qfluentwidgets import isDarkTheme


class DialogBase(QDialog):
    """ Dialog box base class with a mask """

    def __init__(self, parent):
        super().__init__(parent)
        self.setWindowFlags(Qt.FramelessWindowHint)
        self.setAttribute(Qt.WA_TranslucentBackground)
        self.setGeometry(0, 0, parent.width(), parent.height())

    # def showEvent(self, e):
    #     """ fade in """
    #     opacityEffect = QGraphicsOpacityEffect(self)
    #     self.setGraphicsEffect(opacityEffect)
    #     opacityAni = QPropertyAnimation(opacityEffect, b'opacity', self)
    #     opacityAni.setStartValue(0)
    #     opacityAni.setEndValue(1)
    #     opacityAni.setDuration(200)
    #     opacityAni.setEasingCurve(QEasingCurve.InSine)
    #     opacityAni.finished.connect(lambda: self.setGraphicsEffect(None))
    #     opacityAni.start()
    #     super().showEvent(e)
    #
    # def done(self, code):
    #     """ fade out """
    #     opacityEffect = QGraphicsOpacityEffect(self)
    #     self.setGraphicsEffect(opacityEffect)
    #     opacityAni = QPropertyAnimation(opacityEffect, b'opacity', self)
    #     opacityAni.setStartValue(1)
    #     opacityAni.setEndValue(0)
    #     opacityAni.setDuration(100)
    #     opacityAni.finished.connect(lambda: self._onDone(code))
    #     opacityAni.start()
    #
    # def _onDone(self, code):
    #     self.setGraphicsEffect(None)
    #     QDialog.done(self, code)
